import { CreateBook } from '~/pages/BookManage/CreateBookModal'
import request from '../request'
import { UpdateBook } from '~/pages/BookManage/UpdateBookModal'

export function listBook(name?: string) {
    return request({
        method: 'get',
        url: '/book/list',
        params: {
            name,
        },
    })
}

export function createBook(book: CreateBook) {
    return request({
        method: 'post',
        url: '/book/create',
        data: book,
    })
}

export function detailBook(id: number) {
    return request({
        method: 'get',
        url: `/book/${id}`,
    })
}

export function updateBook(book: UpdateBook) {
    return request({
        method: 'put',
        url: `/book/update`,
        data: book,
    })
}

export function deleteBook(id: number) {
    return request({
        method: 'delete',
        url: `/book/delete/${id}`,
    })
}
